﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using ZXCompany.Models.Dao;
using DBUtil;
using ZXCompany.Models.Entity;
namespace ZXCompany.Models.Service
{
    //解决方案
    public class SolutionService
    {
        DaoFactory daofac = new DaoFactory();
        Database db = new Database();
        /// <summary>
        /// 差别化
        /// </summary>
        /// <returns></returns>
        public ZX_Different GetDifferent()
        {
            SqlConnection sconn = db.GetConn();
            try
            {
                sconn.Open();
                return daofac.GetDifferentDao().Select(sconn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.CloseConnection(sconn);
            }
        }

        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="cinfo"></param>
        public void DifInsert(ZX_Different cinfo)
        {
            SqlConnection sconn = db.GetConn();
            try
            {
                sconn.Open();
                daofac.GetDifferentDao().Insert(cinfo, sconn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.CloseConnection(sconn);
            }
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="cinfo"></param>
        public void DifUpdate(ZX_Different cinfo)
        {
            SqlConnection sconn = db.GetConn();
            try
            {
                sconn.Open();
                daofac.GetDifferentDao().Update(cinfo, sconn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.CloseConnection(sconn);
            }
        }

        /// <summary>
        /// 服务流程
        /// </summary>
        /// <returns></returns>
        public ZX_ServiceFlow GetServiceFlow()
        {
            SqlConnection sconn = db.GetConn();
            try
            {
                sconn.Open();
                return daofac.GetServiceFlowDao().Select(sconn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                db.CloseConnection(sconn);
            }
        }
    }
}